"""
求解《百钱百鸡》问题
1只公鸡5元 1只母鸡3元 3只小鸡1元 用100元买100只鸡
问公鸡 母鸡 小鸡各有多少只
"""

chicken_man = 5
chicken_woman = 3
chicken_child = 1 / 3

total = 100

chicken_man_max = int(total / chicken_man)
chicken_woman_max = int(total / chicken_woman)

for man_sum in range(0, chicken_man_max):
    for woman_sum in range(0, chicken_woman_max):
        left_money = total - man_sum * chicken_man - woman_sum * chicken_woman
        if man_sum + woman_sum + left_money / chicken_child == 100:
            print('公鸡：' + str(man_sum) + ' 母鸡:' + str(woman_sum) + ' 小鸡:' + str(left_money * 3))
